Sha256: dd5399883ceb5f0aeedd2721bc8d3bbc4d5897b56254d075c18a5f16afc44d5d
Contents?: true
Size: 1.71 KB
Versions: 10
Compression:
Stored size: 1.71 KB
Contents
describe('editors', () => { beforeEach(() => { mumuki.CustomEditor.clearSources() }) it('has initially no sources', () => { expect(mumuki.CustomEditor.hasSources).toBe(false) }); it('can add a custom source', () => { mumuki.editors.addCustomSource({ getContent() { return { name: "solution[content]", value: 'the value' } ; } }); expect(mumuki.CustomEditor.hasSources).toBe(true); expect(mumuki.CustomEditor.getContents()[0].value).toEqual('the value'); expect(mumuki.CustomEditor.getContents()[0].name).toEqual('solution[content]'); }); it('reads the custom sources if present, ignoring the form', () => { $('body').html(` <form role="form" class="new_solution"> <div class="field form-group editor-code"> <textarea class="form-control editor" name="solution[content]" id="solution_content">the standard solution</textarea> </div> </form>`) mumuki.editors.addCustomSource({ getContent() { return { name: "solution[content]", value: 'the custom solution' } ; } }); expect(mumuki.editors.getSubmission()).toEqual({"solution[content]":"the custom solution"}); }); it('reads the form if no sources', () => { $('body').html(` <form role="form" class="new_solution"> <div class="field form-group editor-code"> <textarea class="form-control editor" name="solution[content]" id="solution_content">the solution</textarea> </div> </form>`) expect(mumuki.editors.getSubmission()).toEqual({"solution[content]":"the solution"}); }); it('produces empty submission if no form nor sources', () => { $('body').html(``); expect(mumuki.editors.getSubmission()).toEqual({}); }); })
Version data entries
10 entries across 10 versions & 1 rubygems