-
Notifications
You must be signed in to change notification settings - Fork 39
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
Showing
14 changed files
with
11,895 additions
and
9,451 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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 |
---|---|---|
|
@@ -3,3 +3,4 @@ | |
dist/ | ||
node_modules/ | ||
doc/ | ||
coverage/ |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,187 @@ | ||
import { | ||
Edit, | ||
EditEvent, | ||
EditEventDetail, | ||
isComplex, | ||
isInsert, | ||
isNamespaced, | ||
isRemove, | ||
isUpdate, | ||
NamespacedAttributeValue, | ||
newEditEvent, | ||
} from './edit-event.js'; | ||
|
||
const doc: XMLDocument = new DOMParser().parseFromString( | ||
`<Document></Document>`, | ||
'application/xml' | ||
); | ||
|
||
describe('edit-event.ts', () => { | ||
const el: Element = doc.createElement('Parent'); | ||
|
||
describe('isComplex', () => { | ||
it('should return true when `Edit` is complex', () => { | ||
const complexEdit: Edit = [ | ||
{ | ||
element: el, | ||
attributes: { | ||
firstname: 'John', | ||
}, | ||
}, | ||
{ | ||
element: el, | ||
attributes: { | ||
lastname: 'Doe', | ||
}, | ||
}, | ||
]; | ||
|
||
expect(isComplex(complexEdit)).toBeTruthy(); | ||
}); | ||
|
||
it('Should return false when `Edit` is simple', () => { | ||
const simpleEdit: Edit = { | ||
element: el, | ||
attributes: { | ||
name: 'John Doe', | ||
}, | ||
}; | ||
|
||
expect(isComplex(simpleEdit)).toBeFalsy(); | ||
}); | ||
}); | ||
|
||
describe('isInsert', () => { | ||
it('Should return true when `Edit` is Insert', () => { | ||
const edit: Edit = { | ||
parent: doc, | ||
node: el, | ||
}; | ||
|
||
expect(isInsert(edit)).toBeTruthy(); | ||
}); | ||
|
||
it('Should return false when `Edit` is Update', () => { | ||
const edit: Edit = { | ||
element: el, | ||
attributes: { | ||
name: 'John Doe', | ||
}, | ||
}; | ||
|
||
expect(isInsert(edit)).toBeFalsy(); | ||
}); | ||
}); | ||
|
||
describe('isNamespaced', () => { | ||
it('Should return true when `value` is Namespaced', () => { | ||
const value: NamespacedAttributeValue = { | ||
value: 'Name', | ||
namespaceURI: 'TEST', | ||
}; | ||
|
||
expect(isNamespaced(value)).toBeTruthy(); | ||
}); | ||
|
||
it('Should return false when `value` is String', () => { | ||
expect(isNamespaced('TEST')).toBeFalsy(); | ||
}); | ||
|
||
it('Should return false when `value` is null', () => { | ||
expect(isNamespaced(null)).toBeFalsy(); | ||
}); | ||
}); | ||
|
||
describe('isUpdate', () => { | ||
it('Should return true when Edit is Update', () => { | ||
const edit: Edit = { | ||
element: el, | ||
attributes: {}, | ||
}; | ||
|
||
expect(isUpdate(edit)).toBeTruthy(); | ||
}); | ||
|
||
it('Should return false when Edit is Insert', () => { | ||
const edit: Edit = { | ||
parent: doc, | ||
node: el, | ||
}; | ||
|
||
expect(isUpdate(edit)).toBeFalsy(); | ||
}); | ||
}); | ||
|
||
describe('isRemove', () => { | ||
it('Should return true when Edit is Remove', () => { | ||
const edit: Edit = { | ||
node: el, | ||
}; | ||
|
||
expect(isRemove(edit)).toBeTruthy(); | ||
}); | ||
|
||
it('Should return false when Edit is Update', () => { | ||
const edit: Edit = { | ||
element: el, | ||
attributes: {}, | ||
}; | ||
|
||
expect(isRemove(edit)).toBeFalsy(); | ||
}); | ||
}); | ||
|
||
describe('newEditEvent', () => { | ||
it('Should have name `oscd-edit`', () => { | ||
const edit: Edit = { | ||
element: el, | ||
attributes: {}, | ||
}; | ||
|
||
const res: EditEvent = newEditEvent(edit); | ||
|
||
expect(res.type).toEqual('oscd-edit'); | ||
}); | ||
|
||
it('Should be composed', () => { | ||
const edit: Edit = { | ||
element: el, | ||
attributes: {}, | ||
}; | ||
|
||
const res: EditEvent = newEditEvent(edit); | ||
|
||
expect(res.composed).toBeTruthy(); | ||
}); | ||
|
||
it('Should be bubble-able', () => { | ||
const edit: Edit = { | ||
element: el, | ||
attributes: {}, | ||
}; | ||
|
||
const res: EditEvent = newEditEvent(edit); | ||
|
||
expect(res.bubbles).toBeTruthy(); | ||
}); | ||
|
||
it('Should have Edit as Detail', () => { | ||
const edit: Edit = { | ||
element: el, | ||
attributes: {}, | ||
}; | ||
|
||
const res: EditEvent = newEditEvent(edit); | ||
|
||
const expectedEventDetail: EditEventDetail<Edit> = { | ||
edit: { | ||
element: el, | ||
attributes: {}, | ||
}, | ||
initiator: 'user', | ||
}; | ||
|
||
expect(res.detail).toEqual(expectedEventDetail); | ||
}); | ||
}); | ||
}); |
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 |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { newOpenEvent, OpenEvent } from './open-event'; | ||
|
||
const doc: XMLDocument = new DOMParser().parseFromString( | ||
`<Document></Document>`, | ||
'application/xml' | ||
); | ||
|
||
describe('open-event.ts', () => { | ||
const docName = 'test.xml'; | ||
|
||
describe('newOpenEvent', () => { | ||
it('Should have name `oscd-open`', () => { | ||
const res: OpenEvent = newOpenEvent(doc, docName); | ||
|
||
expect(res.type).toEqual('oscd-open'); | ||
}); | ||
|
||
it('Should be composed', () => { | ||
const res: OpenEvent = newOpenEvent(doc, docName); | ||
|
||
expect(res.composed).toBeTruthy(); | ||
}); | ||
|
||
it('Should be bubble-able', () => { | ||
const res: OpenEvent = newOpenEvent(doc, docName); | ||
|
||
expect(res.bubbles).toBeTruthy(); | ||
}); | ||
|
||
it('Should have Edit as Detail', () => { | ||
const res: OpenEvent = newOpenEvent(doc, docName); | ||
|
||
expect(res.detail).toEqual({ | ||
docName: docName, | ||
doc: doc, | ||
}); | ||
}); | ||
}); | ||
}); |
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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/** @type {import("ts-jest").JestConfigWithTsJest} */ | ||
module.exports = { | ||
roots: ["<rootDir>"], | ||
preset: "ts-jest", | ||
testEnvironment: "jsdom", | ||
collectCoverage: true, | ||
coverageDirectory: "coverage", | ||
testPathIgnorePatterns: ["/node_modules/"], | ||
|
||
verbose: true, | ||
coverageThreshold: { | ||
global: { | ||
branches: 100, | ||
functions: 100, | ||
lines: 100, | ||
statements: 100, | ||
}, | ||
}, | ||
}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,7 @@ | ||
// Do not modify this file by hand! | ||
// Re-generate this file by running lit-localize | ||
|
||
// Do not modify this file by hand! | ||
// Re-generate this file by running lit-localize | ||
/* eslint-disable no-irregular-whitespace */ | ||
/* eslint-disable @typescript-eslint/no-explicit-any */ | ||
|
||
|
||
|
||
|
||
/* eslint-disable no-irregular-whitespace */ | ||
/* eslint-disable @typescript-eslint/no-explicit-any */ | ||
|
||
export const templates = { | ||
|
||
}; | ||
|
||
export const templates = {}; |
Oops, something went wrong.