-
Notifications
You must be signed in to change notification settings - Fork 0
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
10 changed files
with
102 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import {array_move} from './array_move'; | ||
|
||
it('shifts an item in an array by +1 index', () => { | ||
expect(array_move([1, 2], 0, 1)).toEqual([2, 1]); | ||
}); | ||
|
||
it('shifts an item in an array by -1 index', () => { | ||
expect(array_move([1, 2], 1, 0)).toEqual([2, 1]); | ||
}); |
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,11 @@ | ||
import * as FileSaver from 'file-saver'; | ||
import { downloadAsXml } from './download_as_xml'; | ||
jest.mock('file-saver'); | ||
|
||
it('attempts to save the provided content', () => { | ||
const name = 'foo.xml'; | ||
const xml = '<bar></bar>'; | ||
|
||
downloadAsXml(name, xml); | ||
expect(FileSaver.saveAs).toHaveBeenCalled(); | ||
}); |
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,10 @@ | ||
import { get_cookie } from './get_cookie'; | ||
|
||
Object.defineProperty(window.document, 'cookie', { | ||
writable: true, | ||
value: 'XSRF=FOOBAR', | ||
}); | ||
|
||
it('should retrieve the XSRF Cookie', () => { | ||
expect(get_cookie('XSRF')).toEqual('FOOBAR'); | ||
}); |
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,9 @@ | ||
import { isValidRegex } from './is_valid_regex'; | ||
|
||
it('should return false for a malformed regular expression', () => { | ||
expect(isValidRegex(`\\f;klsdflk;sdf()**(&*&^^()`)).toBe(false) | ||
}); | ||
|
||
it('should return true for a well-formed regular expression', () => { | ||
expect(isValidRegex(`[a-z0-9][a-z0-9-]{0,31}:`)).toBe(true) | ||
}); |
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,14 @@ | ||
import { removeNull } from './remove_null'; | ||
|
||
it('should remove null values from an object', () => { | ||
|
||
const obj = { | ||
foo: null, | ||
bar: { | ||
baz: null | ||
} | ||
}; | ||
|
||
expect(removeNull(obj, true)).toEqual({}); | ||
expect(removeNull(obj, false)).toEqual({bar: { baz: null }}); | ||
}); |
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,5 @@ | ||
import { uuid } from './uuid'; | ||
|
||
it('should return a valid uuid', () => { | ||
expect(uuid()).toMatch(/[0-9a-fA-F]{8}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{12}/); | ||
}); |
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,44 @@ | ||
import React from "react"; | ||
import ReactDOM from 'react-dom'; | ||
import { render, screen } from "@testing-library/react"; | ||
import { act } from 'react-dom/test-utils'; | ||
import { MetadataSchema, useMetadataDefinitionContext } from './MetadataSchema'; | ||
|
||
let container; | ||
beforeEach(() => { | ||
container = document.createElement('div'); | ||
document.body.appendChild(container); | ||
}); | ||
|
||
afterEach(() => { | ||
document.body.removeChild(container); | ||
container = null; | ||
}); | ||
|
||
const Tester = () => { | ||
const definition = useMetadataDefinitionContext(); | ||
|
||
return ( | ||
<> | ||
<>{definition.type}</> | ||
</> | ||
); | ||
} | ||
|
||
|
||
xdescribe("<MetadataSchema />", () => { | ||
/*xact(() => { | ||
ReactDOM.render( | ||
<MetadataSchema type="source"> | ||
<Tester></Tester> | ||
</MetadataSchema>, | ||
container | ||
); | ||
});*/ | ||
|
||
xdescribe("definition context", () => { | ||
it("should provide the type of the definition", () => { | ||
expect(screen.getByText('@MetadataProvider')).toBeTruthy(); | ||
}); | ||
}); | ||
}); |
Empty file.
Empty file.
Empty file.