Skip to content

Commit

Permalink
fixed duplicates and inconsistent tests
Browse files Browse the repository at this point in the history
  • Loading branch information
NoahSaso committed Jun 12, 2024
1 parent 8ad0ce1 commit 79288f1
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
5 changes: 0 additions & 5 deletions src/db/models/WasmCodeKeyId.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import {
BelongsTo,
Column,
Model,
PrimaryKey,
Table,
} from 'sequelize-typescript'

Expand All @@ -19,10 +18,6 @@ import { WasmCodeKey } from './WasmCodeKey'
],
})
export class WasmCodeKeyId extends Model {
@PrimaryKey
@Column
declare id: number

@AllowNull(false)
@Column
declare codeKey: string
Expand Down
2 changes: 1 addition & 1 deletion src/services/wasm-codes/wasm-code.service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ describe('WasmCodeService tests', () => {
}

await WasmCodeKey.createFromKeyAndIds('codeKey1', [1, 2, 3])
await WasmCodeKey.createFromKeyAndIds('codeKey2', [4, 5, 6])
await WasmCodeKey.createFromKeyAndIds('codeKey2', [4, 5, 6, 5, 5, 5])
await WasmCodeKey.createFromKeyAndIds('codeKey3', [1, 3, 5])

await wasmCodeService.reloadWasmCodeIdsFromDB()
Expand Down
9 changes: 7 additions & 2 deletions src/services/wasm-codes/wasm-code.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,15 @@ export class WasmCodeService implements WasmCodeAdapter {
}

/**
* Return a copy of the list of wasm codes.
* Return a sorted list of wasm codes with sorted IDs.
*/
getWasmCodes(): WasmCode[] {
return [...this.wasmCodes]
return this.wasmCodes
.map(
(wasmCode: WasmCode) =>
new WasmCode(wasmCode.codeKey, wasmCode.codeIds.sort())
)
.sort((a, b) => a.codeKey.localeCompare(b.codeKey))
}

/**
Expand Down

0 comments on commit 79288f1

Please sign in to comment.