mirror of
https://github.com/danog/gift.git
synced 2024-11-26 20:04:47 +01:00
46 lines
1.2 KiB
CoffeeScript
46 lines
1.2 KiB
CoffeeScript
should = require 'should'
|
|
fixtures = require './fixtures'
|
|
git = require '../src'
|
|
Blob = require '../src/blob'
|
|
|
|
describe "Blob", ->
|
|
describe "constructor", ->
|
|
repo = fixtures.branched
|
|
blob = new Blob repo, {name: "X", mode: "Y", id: "abc"}
|
|
it "assigns @name", ->
|
|
blob.name.should.eql "X"
|
|
it "assigns @mode", ->
|
|
blob.mode.should.eql "Y"
|
|
it "assigns @id", ->
|
|
blob.id.should.eql "abc"
|
|
|
|
|
|
describe "#data", ->
|
|
describe "of a file off the root", ->
|
|
repo = git "#{__dirname}/fixtures/branched"
|
|
data = null
|
|
before (done) ->
|
|
repo.tree().blobs (err, blobs) ->
|
|
blobs[0].data (err, _data) ->
|
|
data = _data
|
|
done err
|
|
|
|
it "is a string", ->
|
|
data.should.be.a "string"
|
|
data.should.include "Bla"
|
|
|
|
describe "of a file in a subdir", ->
|
|
repo = git "#{__dirname}/fixtures/branched"
|
|
data = null
|
|
before (done) ->
|
|
repo.tree().trees (err, trees) ->
|
|
trees[0].blobs (err, blobs) ->
|
|
blobs[0].data (err, _data) ->
|
|
data = _data
|
|
done err
|
|
|
|
it "is a string", ->
|
|
data.should.be.a "string"
|
|
data.should.include "!!!"
|
|
|