summaryrefslogtreecommitdiff
path: root/tests/frontend/specs/language.js
blob: ab7f2b3d7c4ab07e7b32bf81e8c51771ca8e1003 (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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
function deletecookie(name) {
    document.cookie = name + '=; expires=Thu, 01 Jan 1970 00:00:01 GMT;';
}

describe("Language select and change", function(){
  // Destroy language cookies
  deletecookie("language", null);

  //create a new pad before each test run
  beforeEach(function(cb){
    helper.newPad(cb);
    this.timeout(60000);
  });
 
  // Destroy language cookies

  it("makes text german", function(done) {
    var inner$ = helper.padInner$;
    var chrome$ = helper.padChrome$;
 
    //click on the settings button to make settings visible
    var $settingsButton = chrome$(".buttonicon-settings");
    $settingsButton.click();
 
    //click the language button
    var $language = chrome$("#languagemenu");
    var $languageoption = $language.find("[value=de]");
 
    //select german
    $languageoption.attr('selected','selected');
    $language.change();
 
    helper.waitFor(function() { 
      return chrome$(".buttonicon-bold").parent()[0]["title"] == "Fett (Strg-B)";
     })
    .done(function(){
      //get the value of the bold button
      var $boldButton = chrome$(".buttonicon-bold").parent();
 
      //get the title of the bold button
      var boldButtonTitle = $boldButton[0]["title"];

      //check if the language is now german
      expect(boldButtonTitle).to.be("Fett (Strg-B)");
      done();
    });
  });
 
  it("makes text English", function(done) {
    var inner$ = helper.padInner$;
    var chrome$ = helper.padChrome$;
 
    //click on the settings button to make settings visible
    var $settingsButton = chrome$(".buttonicon-settings");
    $settingsButton.click();
 
    //click the language button
    var $language = chrome$("#languagemenu");
    //select english
    $language.val("en");
    $language.change();
 
    //get the value of the bold button
    var $boldButton = chrome$(".buttonicon-bold").parent();

    helper.waitFor(function() { return $boldButton[0]["title"] != "Fett (Strg-B)";})
    .done(function(){
 
      //get the value of the bold button
      var $boldButton = chrome$(".buttonicon-bold").parent();
 
      //get the title of the bold button
      var boldButtonTitle = $boldButton[0]["title"];
 
      //check if the language is now English
      expect(boldButtonTitle).to.be("Bold (Ctrl-B)");
      done();
 
    });
  });
  
  it("changes direction when picking an rtl lang", function(done) {
    var inner$ = helper.padInner$;
    var chrome$ = helper.padChrome$;
 
    //click on the settings button to make settings visible
    var $settingsButton = chrome$(".buttonicon-settings");
    $settingsButton.click();
 
    //click the language button
    var $language = chrome$("#languagemenu");
    var $languageoption = $language.find("[value=ar]");
 
    //select arabic
    $languageoption.attr('selected','selected');
    $language.val("ar");
    $languageoption.change();

    helper.waitFor(function() { 
      return chrome$("html")[0]["dir"] != 'ltr';
     })
    .done(function(){
      // check if the document's direction was changed
      expect(chrome$("html")[0]["dir"]).to.be("rtl");
      done();
    });
  });

  it("changes direction when picking an ltr lang", function(done) {
    var inner$ = helper.padInner$;
    var chrome$ = helper.padChrome$;

    //click on the settings button to make settings visible
    var $settingsButton = chrome$(".buttonicon-settings");
    $settingsButton.click();

    //click the language button
    var $language = chrome$("#languagemenu");
    var $languageoption = $language.find("[value=en]");

    //select english
    //select arabic
    $languageoption.attr('selected','selected');
    $language.val("en");
    $languageoption.change();

    helper.waitFor(function() {
      return chrome$("html")[0]["dir"] != 'rtl';
     })
    .done(function(){
      // check if the document's direction was changed
      expect(chrome$("html")[0]["dir"]).to.be("ltr");
      done();
    });
  });
});