"use strict";

var assert = require("assert");
var gutil = require("gulp-util");
var ngAnnotate = require("./index");

var ORIGINAL = 'angular.module("test"); m.directive("foo", function($a, $b) {});';
var TRANSFORMED = 'angular.module("test"); m.directive("foo", ["$a", "$b", function($a, $b) {}]);';
var BAD_INPUT = 'angular.module("test").directive("foo", function$a, $b) {});';

describe("gulp-ng-annotate", function() {

  it("should annotate angular declarations", function (done) {
    var stream = ngAnnotate();

    stream.on("data", function (data) {
      assert.equal(data.contents.toString(), TRANSFORMED);
      done();
    });

    stream.write(new gutil.File({contents: new Buffer(ORIGINAL)}));
  });

  it("should not touch already annotated declarations", function (done) {
    var stream = ngAnnotate();

    stream.on("data", function (data) {
      assert.equal(data.contents.toString(), TRANSFORMED);
      done();
    });

    stream.write(new gutil.File({contents: new Buffer(TRANSFORMED)}));
  });

  it("should emit PluginError on bad input", function (done) {
    var stream = ngAnnotate();

    try {
        stream.write(new gutil.File({contents: new Buffer(BAD_INPUT)}));
    } catch (err) {
        assert(err instanceof gutil.PluginError);
        done();
    }
  });

});

@@ -1294,12 +1294,324 @@
 %0A  %7D);%0A%0A
+  it(%22should support passing ng-annotate options%22, function (done) %7B%0A    var stream = ngAnnotate(%7Bremove: true%7D);%0A%0A    stream.on(%22data%22, function (data) %7B%0A      assert.equal(data.contents.toString(), ORIGINAL);%0A      done();%0A    %7D);%0A%0A    stream.write(new gutil.File(%7Bcontents: new Buffer(TRANSFORMED)%7D));%0A  %7D);%0A%0A
 %7D);%0A

Add test for remove option