summaryrefslogtreecommitdiff
path: root/devtools/client/projecteditor/test/helper_edits.js
blob: 17fa2396f312894f794d72da3f547cbce5498638 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/* Any copyright is dedicated to the Public Domain.
 http://creativecommons.org/publicdomain/zero/1.0/ */

"use strict";

var helperEditData = [
  {
    basename: "styles.css",
    path: "css/styles.css",
    newContent: "body,html { color: orange; }"
  },
  {
    basename: "index.html",
    path: "index.html",
    newContent: "<h1>Changed Content Again</h1>"
  },
  {
    basename: "LICENSE",
    path: "LICENSE",
    newContent: "My new license"
  },
  {
    basename: "README.md",
    path: "README.md",
    newContent: "My awesome readme"
  },
  {
    basename: "script.js",
    path: "js/script.js",
    newContent: "alert('hi')"
  },
  {
    basename: "vector.svg",
    path: "img/icons/vector.svg",
    newContent: "<svg></svg>"
  },
];

function* selectFile(projecteditor, resource) {
  ok(resource && resource.path, "A valid resource has been passed in for selection " + (resource && resource.path));
  projecteditor.projectTree.selectResource(resource);

  if (resource.isDir) {
    return;
  }

  let [editorActivated] = yield promise.all([
    onceEditorActivated(projecteditor)
  ]);

  is(editorActivated, projecteditor.currentEditor, "Editor has been activated for " + resource.path);
}