Skip to content

Commit

Permalink
added test for #762
Browse files Browse the repository at this point in the history
  • Loading branch information
schmunk42 committed May 26, 2020
1 parent 844343c commit fe99231
Show file tree
Hide file tree
Showing 4 changed files with 154 additions and 0 deletions.
5 changes: 5 additions & 0 deletions tests/codeceptjs/issues/_test-template.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Feature('t4');

Scenario('test something', (I) => {

});
12 changes: 12 additions & 0 deletions tests/codeceptjs/issues/github-762-required-table-header_test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Feature('issues/github-762');

let themes = new DataTable(['theme']);
themes.add(['spectre']);
themes.add(['bootstrap4']);

Data(themes).Scenario('test required markers', (I, current) => {
I.amOnPage('issues/github-762.html');
I.selectOption('#theme_switcher', current.theme);
I.click('Add row');
I.seeElement('table th.required');
});
74 changes: 74 additions & 0 deletions tests/pages/issues/github-762.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>Test Template</title>
<script src="../../../dist/nonmin/jsoneditor.js"></script>
<link rel='stylesheet' id='theme_stylesheet'>
<link rel='stylesheet' id='iconlib_stylesheet'>
</head>
<body>
<h1>GitHub Issue 762</h1>
<div>
<label>theme</label>
<select id='theme_switcher' name="theme" class='form-control browser-default'>
<option value=''></option>
<option value='barebones'>Barebones</option>
<option value='bootstrap4'>Bootstrap 4</option>
<option value='html'>HTML</option>
<option value='spectre'>Spectre</option>
<option value='tailwind'>Tailwind</option>
</select>
</div>
<div>
<label>iconlib</label>
<select id='iconlib_switcher' name="iconlib" class='form-control browser-default'>
<option value=''></option>
<option value='fontawesome3'>fontawesome 3</option>
<option value='fontawesome4'>fontawesome 4</option>
<option value='fontawesome5'>fontawesome 5</option>
<option value='jqueryui'>jQuery UI</option>
<option value='spectre'>Spectre</option>
</select>
</div>

<div id='editor_holder'></div>

<button id='submit'>Submit (console.log)</button>

<script src="test-helper.js"></script>
<script>
const schema = {
"title": "Table with red star",
"type": "array",
"format": "table",
"items": {
"type": "object",
"required": [
"string1",
"string2"
],
"properties": {
"string1": {
"type": "string"
},
"string2": {
"type": "string"
},
"string3": {
"type": "string"
}
}
}
};

// self executing function here
(function () {
// your page initialization code here
// the DOM will be available here
initJsoneditor();
})();
</script>

</body>
</html>
63 changes: 63 additions & 0 deletions tests/pages/issues/test-helper.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@

let jsoneditor = null
let theme = null
let iconlib = null


const initJsoneditor = (theme, iconlib) => {

if (jsoneditor) {
console.log('...destroy jsoneditor')
jsoneditor.destroy();
}

console.log('...init jsoneditor', theme, iconlib)

jsoneditor = new window.JSONEditor(document.querySelector("#editor_holder"), {
schema: schema,
remove_button_labels: true,
theme: theme,
iconlib: iconlib,
});
}

document.getElementById('theme_switcher').addEventListener('change', function() {
theme = this.value || '';
var mapping = {
barebones: '',
html: '',
bootstrap2: 'https://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/css/bootstrap-combined.min.css',
bootstrap3: 'https://netdna.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css',
bootstrap4: 'https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css',
foundation3: 'https://cdnjs.cloudflare.com/ajax/libs/foundation/3.2.5/stylesheets/foundation.css',
foundation4: 'https://cdnjs.cloudflare.com/ajax/libs/foundation/4.3.2/css/foundation.min.css',
foundation5: 'https://cdnjs.cloudflare.com/ajax/libs/foundation/5.5.3/css/foundation.min.css',
foundation6: 'https://cdnjs.cloudflare.com/ajax/libs/foundation/6.2.4/foundation.min.css',
jqueryui: 'https://code.jquery.com/ui/1.10.3/themes/south-street/jquery-ui.css',
materialize: 'https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/css/materialize.min.css',
spectre: 'https://unpkg.com/spectre.css/dist/spectre.min.css'
};
const link = document.querySelector('#theme_stylesheet').href = mapping[theme];
console.log(link)
initJsoneditor(theme, iconlib)
});

document.getElementById('iconlib_switcher').addEventListener('change',function() {
iconlib = this.value || '';
var mapping = {
bootstrap2: 'https://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/css/bootstrap-combined.min.css',
bootstrap3: 'https://netdna.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css',
fontawesome3: 'https://cdnjs.cloudflare.com/ajax/libs/font-awesome/3.2.1/css/font-awesome.css',
fontawesome4: 'https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.0.3/css/font-awesome.css',
fontawesome5: 'https://use.fontawesome.com/releases/v5.6.1/css/all.css',
foundation3: 'https://cdnjs.cloudflare.com/ajax/libs/foundicons/3.0.0/foundation-icons.css',
jqueryui: 'https://code.jquery.com/ui/1.10.3/themes/south-street/jquery-ui.css',
materialicons: 'https://fonts.googleapis.com/icon?family=Material+Icons',
spectre: 'https://unpkg.com/spectre.css/dist/spectre-icons.min.css'
};

document.querySelector('#iconlib_stylesheet').href = mapping[iconlib];
initJsoneditor(theme, iconlib)
});


0 comments on commit fe99231

Please sign in to comment.