-
-
Notifications
You must be signed in to change notification settings - Fork 113
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
on ValidationContext instance
- Loading branch information
Showing
3 changed files
with
35 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* eslint-disable func-names, prefer-arrow-callback */ | ||
|
||
import expect from 'expect'; | ||
import { SimpleSchema } from './SimpleSchema'; | ||
|
||
describe('SimpleSchema - namedContext', function () { | ||
it('returns a named context', function () { | ||
const schema = new SimpleSchema({}); | ||
const context = schema.namedContext('form'); | ||
expect(context.name).toBe('form'); | ||
expect(schema._validationContexts.form).toBe(context); | ||
}); | ||
|
||
it('returns a context named "default" if no name is passed', function () { | ||
const schema = new SimpleSchema({}); | ||
const context = schema.namedContext(); | ||
expect(context.name).toBe('default'); | ||
expect(schema._validationContexts.default).toBe(context); | ||
}); | ||
|
||
it('returns the same context instance when called with the same name', function () { | ||
const schema = new SimpleSchema({}); | ||
const context1 = schema.namedContext('abc'); | ||
expect(schema._validationContexts.abc).toBe(context1); | ||
const context2 = schema.namedContext('abc'); | ||
expect(context2).toBe(context1); | ||
}); | ||
}); |
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