Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-04-10 15:09:36 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-04-10 15:09:36 +0300
commitc6a33b298229f9e04933be43d6176c476ef03012 (patch)
tree66b336ef374b813d6e9c7f6a19264060a1f23f91 /spec/frontend/ide/services
parentc52b81f45762cb7f05a950689dfc6d51b197ea73 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/ide/services')
-rw-r--r--spec/frontend/ide/services/index_spec.js81
1 files changed, 81 insertions, 0 deletions
diff --git a/spec/frontend/ide/services/index_spec.js b/spec/frontend/ide/services/index_spec.js
index 55f174f4663..658ad37d7f2 100644
--- a/spec/frontend/ide/services/index_spec.js
+++ b/spec/frontend/ide/services/index_spec.js
@@ -42,6 +42,87 @@ describe('IDE services', () => {
});
});
+ describe('getRawFileData', () => {
+ it("resolves with a file's content if its a tempfile and it isn't renamed", () => {
+ const file = {
+ path: 'file',
+ tempFile: true,
+ content: 'content',
+ raw: 'raw content',
+ };
+
+ return services.getRawFileData(file).then(raw => {
+ expect(raw).toBe('content');
+ });
+ });
+
+ it('resolves with file.raw if the file is renamed', () => {
+ const file = {
+ path: 'file',
+ tempFile: true,
+ content: 'content',
+ prevPath: 'old_path',
+ raw: 'raw content',
+ };
+
+ return services.getRawFileData(file).then(raw => {
+ expect(raw).toBe('raw content');
+ });
+ });
+
+ it('returns file.raw if it exists', () => {
+ const file = {
+ path: 'file',
+ content: 'content',
+ raw: 'raw content',
+ };
+
+ return services.getRawFileData(file).then(raw => {
+ expect(raw).toBe('raw content');
+ });
+ });
+
+ it("returns file.raw if file.raw is empty but file.rawPath doesn't exist", () => {
+ const file = {
+ path: 'file',
+ content: 'content',
+ raw: '',
+ };
+
+ return services.getRawFileData(file).then(raw => {
+ expect(raw).toBe('');
+ });
+ });
+
+ describe("if file.rawPath exists but file.raw doesn't exist", () => {
+ let file;
+ let mock;
+ beforeEach(() => {
+ file = {
+ path: 'file',
+ content: 'content',
+ raw: '',
+ rawPath: 'some_raw_path',
+ };
+
+ mock = new MockAdapter(axios);
+ mock.onGet(file.rawPath).reply(200, 'raw content');
+
+ jest.spyOn(axios, 'get');
+ });
+
+ afterEach(() => {
+ mock.restore();
+ });
+
+ it('sends a request to file.rawPath', () => {
+ return services.getRawFileData(file).then(raw => {
+ expect(raw).toEqual('raw content');
+ });
+ });
+ });
+ });
+
describe('getBaseRawFileData', () => {
let file;
let mock;