ngCordovaMocks problem


#1

Hello,

I want to test the following code on my browser (firefox) got the error: "Error: cordova is not defined"
I use “ng-cordova-mocks.js”.
Thank you for your help

index.html

...
    <script src="lib/ngCordova/dist/ng-cordova-mocks.js"></script> 
    <script src="cordova.js"></script>
...

app.js

'use strict';

var app = angular.module('myTest', ['ionic', 'ngCordovaMocks'])

app.run(function ($ionicPlatform) {
    $ionicPlatform.ready(function () {
        // Hide the accessory bar by default (remove this to show the accessory bar above the keyboard
        // for form inputs)
        if (window.cordova && window.cordova.plugins.Keyboard) {
            cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
        }
        if (window.StatusBar) {
            StatusBar.styleDefault();
        }
    });
})

itemProviders.js

'use strict';

var items = [
{ 'id': '2', 'name': 'toto' },
{ 'id': '3', 'name': 'titi },
];


app.service('itemProvider', function ($ionicPlatform,$cordovaFile) {

    this.getItems = function () {
        return items;
    }
    
    this.create = function (item) {
  
        $ionicPlatform.ready(function () {

                  $cordovaFile.writeFile(cordova.file.dataDirectory, "test.json", items, true)
                      .then(function (success) {
                          // success
                      }, function (error) {
                          // error
                  });
           
        });
    }
})