-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5f2a4bd
commit 268eb5b
Showing
7 changed files
with
115 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,92 @@ | ||
import { describe, it, expect } from 'vitest'; | ||
import { describe, it, expect } from "vitest"; | ||
import type { Shift, Location, Person, Task, Skill } from "$lib/types"; | ||
import * as devalue from "devalue"; | ||
import { | ||
generateLocation, | ||
generatePerson, | ||
generateShift, | ||
generateSkill, | ||
generateTask | ||
} from "$lib/testing.ts"; | ||
|
||
describe('sum test', () => { | ||
it('adds 1 + 2 to equal 3', () => { | ||
expect(1 + 2).toBe(3); | ||
}); | ||
describe("Serialization", () => { | ||
it("should serialize a location", () => { | ||
const location: Location = generateLocation(); | ||
|
||
const serialized = devalue.stringify(location); | ||
console.log(serialized); | ||
|
||
expect(serialized).toBeDefined(); | ||
|
||
const deserialized = devalue.parse(serialized); | ||
console.log(deserialized); | ||
|
||
expect(deserialized).toBeDefined(); | ||
expect(deserialized).toBeTypeOf("object"); | ||
expect(deserialized).toEqual(location); | ||
}); | ||
|
||
it("should serialize a person", () => { | ||
const person: Person = generatePerson(); | ||
|
||
const serialized = devalue.stringify(person); | ||
console.log(serialized); | ||
|
||
expect(serialized).toBeDefined(); | ||
|
||
const deserialized = devalue.parse(serialized); | ||
console.log(deserialized); | ||
|
||
expect(deserialized).toBeDefined(); | ||
expect(deserialized).toBeTypeOf("object"); | ||
expect(deserialized).toEqual(person); | ||
}); | ||
|
||
it("should serialize a task", () => { | ||
const task: Task = generateTask(); | ||
|
||
const serialized = devalue.stringify(task); | ||
console.log(serialized); | ||
|
||
expect(serialized).toBeDefined(); | ||
|
||
const deserialized = devalue.parse(serialized); | ||
console.log(deserialized); | ||
|
||
expect(deserialized).toBeDefined(); | ||
expect(deserialized).toBeTypeOf("object"); | ||
expect(deserialized).toEqual(task); | ||
}); | ||
|
||
it("should serialize a shift", () => { | ||
const shift: Shift = generateShift(); | ||
|
||
const serialized = devalue.stringify(shift); | ||
console.log(serialized); | ||
|
||
expect(serialized).toBeDefined(); | ||
|
||
const deserialized = devalue.parse(serialized); | ||
console.log(deserialized); | ||
|
||
expect(deserialized).toBeDefined(); | ||
expect(deserialized).toBeTypeOf("object"); | ||
expect(deserialized).toEqual(shift); | ||
}); | ||
|
||
it("should serialize a skill", () => { | ||
const skill: Skill = generateSkill(); | ||
|
||
const serialized = devalue.stringify(skill); | ||
console.log(serialized); | ||
|
||
expect(serialized).toBeDefined(); | ||
|
||
const deserialized = devalue.parse(serialized); | ||
console.log(deserialized); | ||
|
||
expect(deserialized).toBeDefined(); | ||
expect(deserialized).toBeTypeOf("object"); | ||
expect(deserialized).toEqual(skill); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters