Paragraph with inline element
diff --git a/package.json b/package.json index 04f76bc1..0f2bc367 100644 --- a/package.json +++ b/package.json @@ -68,7 +68,8 @@ "file-loader": "^0.8.5", "identity-obj-proxy": "^3.0.0", "imports-loader": "^0.6.5", - "jest-cli": "^16.0.1", + "jest": "19.1.0-alpha.eed82034", + "jest-cli": "19.1.0-alpha.eed82034", "lint-staged": "^3.1.0", "node-sass": "^3.10.0", "npm-check": "^5.2.3", @@ -101,7 +102,6 @@ "history": "^2.1.2", "immutability-helper": "^2.0.0", "immutable": "^3.7.6", - "jest": "^17.0.0", "js-base64": "^2.1.9", "js-yaml": "^3.7.0", "json-loader": "^0.5.4", diff --git a/src/backends/github/API.js b/src/backends/github/API.js index ef7765bf..4bd8ddda 100644 --- a/src/backends/github/API.js +++ b/src/backends/github/API.js @@ -393,7 +393,7 @@ export default class API { return this.deleteRef("heads", branchName); } - createPR(title, head, base = "master") { + createPR(title, head, base = this.branch) { const body = "Automatically generated by Netlify CMS"; return this.request(`${ this.repoURL }/pulls`, { method: "POST", @@ -518,5 +518,4 @@ export default class API { body: JSON.stringify({ message, tree, parents }), }); } - } diff --git a/src/backends/github/__tests__/API.spec.js b/src/backends/github/__tests__/API.spec.js new file mode 100644 index 00000000..ba665961 --- /dev/null +++ b/src/backends/github/__tests__/API.spec.js @@ -0,0 +1,39 @@ +import AssetProxy from "../../../valueObjects/AssetProxy"; +import API from "../API"; + +describe('github API', () => { + const mockAPI = (api, responses) => { + api.request = (path, options = {}) => { + const normalizedPath = path.indexOf('?') !== -1 ? path.substr(0, path.indexOf('?')) : path; + const response = responses[normalizedPath]; + return typeof response === 'function' + ? Promise.resolve(response(options)) + : Promise.reject(new Error(`No response for path '${normalizedPath}'`)) + }; + } + + it('should create PR with correct base branch name when publishing with editorial workflow', () => { + let prBaseBranch = null; + const api = new API({ branch: 'gh-pages', repo: 'my-repo' }); + const responses = { + '/repos/my-repo/branches/gh-pages': () => ({ commit: { sha: 'def' } }), + '/repos/my-repo/git/trees/def': () => ({ tree: [] }), + '/repos/my-repo/git/trees': () => ({}), + '/repos/my-repo/git/commits': () => ({}), + '/repos/my-repo/git/refs': () => ({}), + '/repos/my-repo/pulls': (pullRequest) => { + prBaseBranch = JSON.parse(pullRequest.body).base; + return { head: { sha: 'cbd' } }; + }, + '/user': () => ({}), + '/repos/my-repo/git/blobs': () => ({}), + '/repos/my-repo/git/refs/meta/_netlify_cms': () => ({ 'object': {} }) + }; + mockAPI(api, responses); + + return expect( + api.editorialWorkflowGit(null, { slug: 'entry', sha: 'abc' }, null, {}) + .then(() => prBaseBranch) + ).resolves.toEqual('gh-pages') + }); +}); diff --git a/src/components/EntryEditor/__tests__/__snapshots__/EntryEditorToolbar.spec.js.snap b/src/components/EntryEditor/__tests__/__snapshots__/EntryEditorToolbar.spec.js.snap index 801382be..f51fe48a 100644 --- a/src/components/EntryEditor/__tests__/__snapshots__/EntryEditorToolbar.spec.js.snap +++ b/src/components/EntryEditor/__tests__/__snapshots__/EntryEditorToolbar.spec.js.snap @@ -1,3 +1,5 @@ -exports[`EntryEditorToolbar should disable and update label of Save button when persisting 1`] = `"
Paragraph with inline element
Use the printf()
function.
There is a literal backtick (\`) here.
Text with bold & em elements
Text with bold & em elements