-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #72 from jaredwray/adding-in-vitest-for-testing-mo…
…ving-forward adding in vitest
- Loading branch information
Showing
8 changed files
with
145 additions
and
10 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
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,79 @@ | ||
import {describe, test, expect} from 'vitest'; | ||
import {HelperRegistry, HelperRegistryCompatibility} from '../src/helper-registry.js'; | ||
|
||
describe('HelperRegistry', () => { | ||
test('should have helpers', () => { | ||
const registry = new HelperRegistry(); | ||
expect(registry).toBeDefined(); | ||
}); | ||
}); | ||
|
||
describe('HelperRegistry Register', () => { | ||
test('should register a helper', () => { | ||
const registry = new HelperRegistry(); | ||
registry.register({ | ||
name: 'test', | ||
category: 'test', | ||
fn: () => 'test', | ||
}); | ||
expect(registry.has('test')).toBeTruthy(); | ||
}); | ||
|
||
test('should not register a helper twice', () => { | ||
const registry = new HelperRegistry(); | ||
const helper = { | ||
name: 'test', | ||
category: 'test', | ||
fn: () => 'test', | ||
}; | ||
registry.register(helper); | ||
expect(registry.register(helper)).toBeFalsy(); | ||
}); | ||
}); | ||
|
||
describe('HelperRegistry Filter', () => { | ||
test('should return nothing filter by name', () => { | ||
const registry = new HelperRegistry(); | ||
registry.register({ | ||
name: 'test', | ||
category: 'test', | ||
fn: () => 'test', | ||
}); | ||
expect(registry.filter({name: 'test1'}).length).toBe(1); | ||
}); | ||
test('should filter by name', () => { | ||
const registry = new HelperRegistry(); | ||
registry.register({ | ||
name: 'test', | ||
category: 'test', | ||
fn: () => 'test', | ||
}); | ||
expect(registry.filter({name: 'test'}).length).toBe(1); | ||
}); | ||
test('should filter by category', () => { | ||
const registry = new HelperRegistry(); | ||
registry.register({ | ||
name: 'test', | ||
category: 'test', | ||
fn: () => 'test', | ||
}); | ||
registry.register({ | ||
name: 'test2', | ||
category: 'test2', | ||
fn: () => 'test2', | ||
}); | ||
expect(registry.filter({category: 'test'}).length).toBe(1); | ||
}); | ||
|
||
test('should filter by compatibility', () => { | ||
const registry = new HelperRegistry(); | ||
registry.register({ | ||
name: 'test', | ||
category: 'test', | ||
compatibility: HelperRegistryCompatibility.BROWSER, | ||
fn: () => 'test', | ||
}); | ||
expect(registry.filter({compatibility: HelperRegistryCompatibility.BROWSER}).length).toBe(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,24 @@ | ||
import {describe, test, expect} from 'vitest'; | ||
import { | ||
helpers, handlebars, createHandlebars, fumanchu, | ||
} from '../src/index.js'; | ||
|
||
describe('fumanchu', () => { | ||
test('should have helpers', () => { | ||
expect(helpers).toBeDefined(); | ||
}); | ||
|
||
test('should have handlebars', () => { | ||
expect(handlebars).toBeDefined(); | ||
}); | ||
|
||
test('should be able to createHandlebars', async () => { | ||
const handlebars = await createHandlebars(); | ||
expect(handlebars).toBeDefined(); | ||
}); | ||
|
||
test('should be able to run fumanchu()', () => { | ||
const handlebars = fumanchu(); | ||
expect(handlebars).toBeDefined(); | ||
}); | ||
}); |
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,18 @@ | ||
import {defineConfig} from 'vitest/config'; | ||
|
||
export default defineConfig({ | ||
test: { | ||
coverage: { | ||
reporter: ['lcov', 'text'], | ||
exclude: [ | ||
'**/node_modules/**', | ||
'helpers/**', | ||
'vitest.config.ts', | ||
'site/**', | ||
'dist/**', | ||
'dist-site/**', | ||
'test/**', | ||
], | ||
}, | ||
}, | ||
}); |